home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu086.dms / pu086.adf / bin / Bugs.doc < prev    next >
Text File  |  1990-12-02  |  11KB  |  373 lines

  1.  
  2.   (c) 1990 S.Hawtin.
  3.   Permission is granted to copy this file and NorthC provided that:
  4.    1) Neither are used for commercial gain
  5.    2) This notice is included in all copies
  6.    3) Altered copies are marked as such
  7.    4) Each copy of NorthC is accompanied by a copy of this file.
  8.  
  9.   No liability is accepted for the contents of the file or the NorthC 
  10. program.
  11.  
  12.   Bugs.doc      within        NorthC
  13.  
  14.   This file gives some hints about problems with "NorthC" programs, if you 
  15. find that a program you have compiled is behaving in a way you really 
  16. cannot explain and "libc.doc" is no help, you should read this file.
  17.  
  18.   This file is split into three sections, first the list of known bugs in 
  19. the current release, next a list of bugs fixed by this and previous 
  20. releases and finally a list of "hints".
  21.  
  22.   The known bugs are listed under the release that they were first noticed 
  23. in, the fixes are listed under the release that they were implemented in.
  24.  
  25.   The "hints" cover everything from bugs I have no immediate intention of 
  26. fixing to problems with the 'C' language that have caught me out in the past.
  27.  
  28.  Bugs
  29.  ****
  30.  
  31.  Version 1.2
  32.  ***********
  33.  
  34. 1.2.6  unsigned short Function Arguments
  35.  
  36.   Because all integers are now four bytes there seems to be a problem with 
  37. functions that have unsigned short arguments.  The calling function expands 
  38. these two byte values into four bytes but the called function assumes they 
  39. are two bytes long, and ... WOWEE we have messed the stack up.
  40.  
  41. 1.2.7  "%hd" qualifier in printf
  42.  
  43.   The short qualifier "h" does not work in printf.
  44.  
  45. 1.2.16  addq.w after function calls (from M.Combs)
  46.  
  47.   After function calls the stack is restored with an "addq.w" instruction 
  48. this should be "addq.l" in case we have the stack on a block boundary.
  49.  
  50. 1.2.17  "top" running on static variables within functions
  51.  
  52.   When "top" attempts to optimise static variables within function it 
  53. give an error.
  54.  
  55. 1.2.18  alignment
  56.  
  57.   NorthC is very bad at aligning object in memory, look out for odd length 
  58. strings, and struture elements that are single bytes.
  59.  
  60. 1.2.19  enum with auto variables
  61.  
  62.   Enumerated sets seem not to work with non static variables within 
  63. functions.
  64.  
  65. 1.2.20  undefined substructures
  66.  
  67.   If you define a structure with an undefined substructure NorthC will 
  68. not give an error message, as it should.
  69.  
  70. 1.2.22  Cast treated as run time operation
  71.  
  72.   The switch statement cannot cope with a value that includes a cast, even 
  73. when the result should be a constant.  This error also affects the way 
  74. arrays are defined.
  75.  
  76. 1.2.24  Unnamed structures
  77.  
  78.   If a structure type is not named NorthC will generate a name for it, so 
  79. the sequence
  80.  
  81.     typedef struct
  82.        {int foo;
  83.         char *baz;
  84.         } FooBaz;
  85.  
  86. will generate a name for the, this will be S followed by the line number, 
  87. so if the structure starts on line 60 of the file the definition would act 
  88. as though you had inserted
  89.  
  90.     typedef struct S60
  91.        {int foo;
  92.         char *baz;
  93.         } FooBaz;
  94.  
  95. this is all right, unless another include file defines an unnamed structure 
  96. on its line 60, if that happens you will be told about redefining the 
  97. structure S60.  The quickest way to fix this is to name the structure, for 
  98. example
  99.  
  100.     typedef struct _FooBaz
  101.        {int foo;
  102.         char *baz;
  103.         } FooBaz;
  104.  
  105.  Version 1.1
  106.  ***********
  107.  
  108. 1.1.1  Standard C
  109.  
  110.   There are a number of features of ANSI 'C' that are not implemented in 
  111. NorthC.  NorthC is a fairly standard Kernigan & Ritchie first edition 'C' 
  112. that has been extended to move towards ANSI.
  113.  
  114.   The features that I know are missing are
  115.  
  116.     a)  locales
  117.     b)  structure returns
  118.     c)  function prototypes
  119.     d)  #pragma #val #error
  120.     e)  The '#' and '##' operators
  121.     f)  concatenating adjacent strings
  122.     g)  multibyte characters
  123.     h)  floats & doubles are too small
  124.     i)  volatile and const storage classes
  125.  
  126. 1.1.2  Assignments in if statements
  127.  
  128.   The assignment operator can be incorrectly optimised away in some 
  129. situations, for example the code
  130.  
  131.     if(x=7)
  132.        {printf("foo");
  133.         }
  134.  
  135. will notice that the assignment always returns a true value and so will 
  136. just call printf() without bothering to perform the assignment.  The 
  137. obvious fix is to convert the code to
  138.  
  139.     x=7;
  140.     printf("foo");
  141.  
  142. to force the assignment.  If you typed the first code fragment I would 
  143. imagine that you meant
  144.  
  145.     if(x==7)
  146.        {printf("foo");
  147.         }
  148.  
  149. which is entirely different and of course works.
  150.  
  151. 1.1.3  Library functions
  152.  
  153.   The library functions do not always act as expected, see "libc.doc" for 
  154. a complete description of the bugs and omissions.
  155.  
  156.   The system() function always returns -1 regardless of the value returned 
  157. by the called program.
  158.  
  159.   scanf() does not fully support floating point numbers, see the note in 
  160. the Hints section.
  161.  
  162. 1.1.5  Program name
  163.  
  164.   When a program is started up it should have its name in argv[0], however 
  165. NorthC always sets this string to "".  This will confuse some programs, 
  166. for example the UNIX "uncompress" and "compress" programs rely on knowing 
  167. the name they were called with.
  168.  
  169. 1.1.6  fseek()
  170.  
  171.   There are some occasions when fseek() functions incorrectly, as yet I 
  172. have no consistent example of this bug.
  173.  
  174.  Release 1.0
  175.  ***********
  176.  
  177.   All the bugs reported in release 1.0 have been fixed.
  178.  
  179.  Fixes
  180.  *****
  181.  
  182.   Here is a list of previously noted bugs that are now fixed.
  183.  
  184. Release 1.3
  185. ***********
  186.  
  187. 1.2.10  static strings in functions
  188.  
  189. 1.2.11  bsr in crt0.asm
  190.  
  191. 1.2.12  realloc
  192.  
  193. 1.2.13  && and ||
  194.  
  195. 1.2.14  cc (from Richard Johnston)
  196.  
  197. 1.2.15  Floating point comparisons
  198.  
  199. 1.2.21  large values in switch statements
  200.  
  201. 1.2.23  WORD in types.h is signed
  202.  
  203.  Release 1.2
  204.  ***********
  205.  
  206. 1.2.1  strtol()
  207.  
  208. 1.1.4  Clearing address registers
  209.  
  210. 1.0.1a  Declarations inside functions
  211.  
  212. 1.2.2  #undef (from M.Combs)
  213.  
  214. 1.2.4  Initialised static arrays in functions
  215.  
  216. 1.2.5  fgetc() return value.
  217.  
  218. 1.2.3  open() in the UNIX library
  219.  
  220. 1.2.8  Initialising unsigned char arrays (from M.Combs)
  221.  
  222. 1.2.9  ctime() and asctime() (from M.Combs)
  223.  
  224.  Release 1.1
  225.  ***********
  226.  
  227. 1.0.1b  Declarations inside functions
  228.  
  229.  Hints
  230.  *****
  231.  
  232.   Large numbers of functions have not yet been implemented, or behave 
  233. differently from ANSI, see the "libc.doc" file for details.  If you find 
  234. any functions that you really need are not yet done you will have to write 
  235. them yourself.
  236.  
  237.   scanf() and all its relatives, behave in counter intuitive ways.  If you 
  238. use these functions you might have problems getting programs to work, and 
  239. you will certainly have problems porting your programs between machines, I 
  240. know for sure that there is a difference between NorthC scanf() and the 
  241. one in UNIX V.  However the version of scanf() under UNIX doesn't work 
  242. either.  I might not fix this problem, I have yet to find two versions of 
  243. 'C' that do the same thing with scanf(), I would recommend you just don't 
  244. use it.
  245.  
  246.   If the compiler suddenly starts crashing the machine whenever it is run 
  247. check how full the disk is.  If the OS returns a "disk full" error the 
  248. compiler may just carry on writing to the disk regardless.
  249.  
  250.   If your program dies with a message like "Error: 1004" this indicates a 
  251. library error, look in the ":include/errno.h" file to find out what the 
  252. library function is complaining about, or use the strerror() function.
  253.  
  254.   The compiler examines the value of the "INCLUDE" environment variable 
  255. and adds the listed directories to its include directories.  Separate 
  256. directories should have a ',' character between them.  For example to look 
  257. on the directories "df1:foo" "//jim" and "fred" issue the CLI command 
  258.  
  259.     setenv INCLUDE "df1:foo,//jim,fred"
  260.  
  261. this feature has not been fully tested yet so it may be interesting to use.
  262.  
  263.   Here is a classic mistake that all real 'C' programmers must make at 
  264. least once, beware of the difference between
  265.  
  266.     if(jim==foo())
  267.        {.
  268.         .
  269.         }
  270.  
  271. and
  272.  
  273.     if(jim=foo())
  274.        {.
  275.         .
  276.         }
  277.  
  278. one of these is an assignment the other is a test, both are valid 'C'.  
  279. Some programmers guard against this by using
  280.  
  281.     #define EQ ==
  282.     .
  283.     .
  284.     if(jim EQ foo())
  285.        {.
  286.         .
  287.         }
  288.  
  289. of course you would put the first definition in an include file, 
  290. "easyC.h"for example.
  291.  
  292.  
  293.   Large programs may cause Blink to have some problems, if you find that 
  294. some symbols refuse to link in very large programs try setting the 
  295. "SMALLCODE" flag.  If you keep finding that Blink is failing to link 
  296. symbols you know are defined try linking with the command
  297.  
  298.     cc -ooutname -bSMALLCODE foo.o bar.o baz.o
  299.  
  300. this fixes the problem for my largest program, NorthC.
  301.  
  302.   In general if the linker is causing problems it is worth setting it to 
  303. verbose, us a command such as
  304.  
  305.     cc -ooutname -bVERBOSE foo.o bar.o baz.o
  306.  
  307. this will at least give a clue as to where the linker problem was.
  308.  
  309.   There is no way at the moment to handle interrupts within NorthC, this 
  310. should be fixed when I find a book that explains what to do to handle them 
  311. in AmigaDOS.
  312.  
  313.   If you want to play with assembler then just call "NorthC" on your ".c" 
  314. file, this will produce a ".s" file that you can examine.  The "make" 
  315. program knows how to create object files from ".s" files.
  316.  
  317.   Look at "crt0.asm" to see how I have used the assembler, there may be 
  318. some good ideas to steal.
  319.  
  320.   When writing assembler be sure to restore the registers before you 
  321. return, NorthC expects you to alter the registers d0 d1 a0 and a1 but any 
  322. other registers must be restored or else very nasty things can happen.
  323.  
  324.   If you want to play with the low levels of the operating system I would 
  325. recommend that you use the debug() routine a lot.
  326.  
  327.   Here is another classic 'C' mistake,
  328.  
  329.     jim = 4;
  330.     joe = jim<<2 + 3;
  331.  
  332. this will set joe to 128, not 19 as you might expect (well I would).  When 
  333. using the shift operator always put brackets to make the nesting obvious.
  334.  
  335.   Array indices always start at 0 and go up to the number of elements 
  336. minus one.  This can have some interesting effect, for example the function
  337.  
  338.     foo()
  339.        {
  340.         int i;
  341.         int array[4];
  342.  
  343.         for(i=0;i<=4;i++)
  344.             array[i] = 0;
  345.         .
  346.         .
  347.         }
  348.  
  349. could be an infinite loop, because when the function sets array[4] to zero 
  350. it actually sets i to zero.
  351.  
  352.   Always use the system include files to define the library functions, for 
  353. example if you write some code
  354.  
  355.     foo()
  356.        {extern long atol();
  357.         .
  358.         .
  359.         jim = atol(str);
  360.         }
  361.  
  362. then NorthC will give an error message, this is because atol() is defined 
  363. as a macro in NorthC.  The correct way to access the function is
  364.  
  365.     #include <stdlib.h>
  366.  
  367.     foo()
  368.        {
  369.         jim = atol(str);
  370.         }
  371.  
  372. this will obtain the correct definition from the "stddef.h" file.
  373.